home *** CD-ROM | disk | FTP | other *** search
- FastWait Copyright (c) 1991 Southern Software
-
- Version 1.00 - 4/8/91
-
- Allows PC's faster than 20 mhz (386/486) to properly use a delay
- function based upon a null looping procedure such as is used in the
- Turbo Pascal "Delay" procedure. Wait is accurate for PC's as fast as
- 1,100 mhz equivalent!
-
- USAGE: Simply place "FastWait" in the Uses section of your program
- and replace each occurrence of "delay" in your program with
- "wait".
-
- Example-
- =======
-
- Existing program:
- ----------------
- Uses CRT;
-
- begin
- writeln('This program delays for 5 seconds.);
- delay(5000);
- end.
-
- New program:
- -----------
- Uses FastWait, CRT; {Now also uses "FastWait"}
-
- begin
- writeln('This program delays for 5 seconds.);
- wait(5000); {changed "delay" to "wait"}
- end.
-
-
- User accessible variables in FastWait unit:
- ------------------------------------------
-
- WaitOneMS : Number of loops required for one millisecond delay
- LoopsPerTick : LongInt which is # loops in timer for one
- BIOS tick (18.2 ticks per second)
- BIOSTick : An absolute LongInt variable into the PC BIOS area
- which is the system counter and is incremented 18.2
- times per second.
-
-
-
- Procedure in FastWait unit:
- --------------------------
-
- procedure Wait( ms : word );
-
- procedure ShortDelay(NumLoops : word);
- {
- This procedure is for very short timing loops ( < 1ms) that cannot be
- handled by the delay routine.
-
- The variable "LoopsPerTick" has the number of loops to do for one BIOS
- tick (18.2 of these/sec). If you want to delay for "X" µs, the number
- of loops required would be "(LoopsPerTick*X) div 54945"
-
- This will not compile if you are using TP 4.0, 5.0 or 5.5 due to the
- conditional defines. This is because it makes use of the "asm"
- statement which is not available in TP versions prior to 6.0.
- }
-
-
-
- Technical Discussion
- --------------------
- In the Turbo CRT unit, there has been a word variable named "DelayCnt"
- (local variable to the CRT unit) which is the number of loops that
- were done in one clock tick divided by 55. This is a decent approx-
- imation of the number of loops required for one millisecond (the
- "Delay" procedure merely called a null loop "DelayCnt" times for each
- millisecond specified in the call to the procedure. (Note- For those
- using Object Professional or Turbo Professional, this variable is called
- "OneMS", but the logic is identical).
-
- Unfortunately, if the clock speed gets to about 25 mhz, the PC is so
- fast that the PC can do more than 65,535 loops and the null loop timer
- does not work. The value 65,535 is divided by 55 to give 1,191
- regardless of the speed of the PC. Subsequent calls to the delay
- procedure cause shorter-than-expected delays since the delay count
- calculated for one millisecond is too low. This problem gets worse the
- faster the PC becomes.
-
- The "Wait" procedure is a simple solution to this problem. The number
- of loops done in one clock tick is stored in a LongInt rather than a
- word variable so the limit of 65,535 loops in one clock tick is not a
- problem.
-
- Special goody if you are using TP 6.0+ (or if you want to make the
- assembly code below in a separate ASM file) -- A routine called
- "ShortDelay" is provided which will be included in the FastWait unit
- automatically if you are using TP 6.0+ that allows you to specify
- delays which are shorter than 1 millisecond (the lower limit of
- the "delay" and "wait" routines.
-
-
- Public Usage
- ------------
- This utility is provided for the public domain on an as-is basis
- free of charge. It may be used in any programs with no royalties.
- Southern Software retains all rights to the code and is not liable
- for anything which may happen as a result of using the code.
-
-
- ----------------end-of-author's-documentation---------------
-
- Software Library Information:
-
- This disk copy provided as a service of
-
- Public (software) Library
-
- We are not the authors of this program, nor are we associated
- with the author in any way other than as a distributor of the
- program in accordance with the author's terms of distribution.
-
- Please direct shareware payments and specific questions about
- this program to the author of the program, whose name appears
- elsewhere in this documentation. If you have trouble getting
- in touch with the author, we will do whatever we can to help
- you with your questions. All programs have been tested and do
- run. To report problems, please use the form that is in the
- file PROBLEM.DOC on many of our disks or in other written for-
- mat with screen printouts, if possible. PsL cannot debug pro-
- programs over the telephone, though we can answer questions.
-
- Disks in the PsL are updated monthly, so if you did not get
- this disk directly from the PsL, you should be aware that the
- files in this set may no longer be the current versions. Also,
- if you got this disk from another vendor and are having prob-
- lems, be aware that some files may have become corrupted or
- lost by that vendor. Get a current, working disk from PsL.
-
- For a copy of the latest monthly software library newsletter
- and a list of the 3,000+ disks in the library, call or write
-
- Public (software) Library
- P.O.Box 35705 - F
- Houston, TX 77235-5705
-
- 1-800-2424-PSL
- MC/Visa/AmEx/Discover
-
- Outside of U.S. or in Texas
- or for general information,
- Call 1-713-524-6394
-
- PsL also has an outstanding
- catalog for the Macintosh.
-